﻿using System;
using System.Collections.Generic;

namespace TempEmployees.BLL.Validations
{
    public class ValidationMethodFactory
    {
        public delegate bool IsValidDelegate(object data);

        public static Dictionary<string, IsValidDelegate> m_delegateMappings = new Dictionary<string,IsValidDelegate>();

        static ValidationMethodFactory()
        {
            m_delegateMappings.Add("BirthDate", BirthDate.IsValid);
            m_delegateMappings.Add("Date", DateField.IsValid);
            m_delegateMappings.Add("Email", Email.IsValid);
            m_delegateMappings.Add("IdentityNumber", IdentityNumber.IsValid);
            m_delegateMappings.Add("MonthlyHours", MonthlyHours.IsValid);
            m_delegateMappings.Add("PhoneNumber", PhoneNumber.IsValid);
            m_delegateMappings.Add("Salary", SalaryField.IsValid);
        }

        public static IsValidDelegate GetValidationMethod(string validationType)
        {
            if (!string.IsNullOrEmpty(validationType) && m_delegateMappings.ContainsKey(validationType)) return m_delegateMappings[validationType];
            return DefaultValidator;
        }

        public static bool DefaultValidator(object data)
        {
            return true;
        }
    }
}